package com.fortune.controller.acl;

import com.fortune.common.acl.JsonData;
import com.fortune.dto.acl.MAclModuleParam;
import com.fortune.service.acl.MAclModuleService;
import com.fortune.service.acl.MTreeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

//@Controller
@RequestMapping("/m/aclModule")
@Slf4j
public class MAclModuleController {

    @Resource
    private MAclModuleService mAclModuleService;
    @Resource
    private MTreeService mTreeService;

    @RequestMapping("/save")
    @ResponseBody
    public JsonData saveAclModule(MAclModuleParam param) {
        mAclModuleService.save(param);
        return JsonData.success();
    }

    @RequestMapping("/update")
    @ResponseBody
    public JsonData updateAclModule(MAclModuleParam param) {
        mAclModuleService.update(param);
        return JsonData.success();
    }

    @RequestMapping("/tree")
    @ResponseBody
    public JsonData tree() {
        return JsonData.success(mTreeService.aclModuleTree());
    }

    @RequestMapping("/delete")
    @ResponseBody
    public JsonData delete(@RequestParam("id") int id) {
        mAclModuleService.delete(id);
        return JsonData.success();
    }
}
